$(function () {

    //操作时间
    $('#cTime_start').daterangepicker({
        "singleDatePicker": true,
        "timePicker": true,
        "timePicker24Hour": true,
        "timePickerSeconds": true,
        "parentEl": "200",
        locale: {
            format:'YYYY-MM-DD HH:mm:ss',
            applyLabel: '确认',
            cancelLabel: '取消',
            weekLabel: 'W',
            customRangeLabel: 'Custom Range',
            daysOfWeek:["日","一","二","三","四","五","六"],
            monthNames: ["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]
        }
    }, function(start, end, label) {
        $('#cTime_start').val(start.format('YYYY-MM-DD HH:mm:ss'));
    });
    $("#cTime_start").val("");//清空控件默认时间

    $('#cTime_end').daterangepicker({
        "singleDatePicker": true,
        "timePicker": true,
        "timePicker24Hour": true,
        "timePickerSeconds": true,
        "parentEl": "200",
        locale: {
            format:'YYYY-MM-DD HH:mm:ss',
            applyLabel: '确认',
            cancelLabel: '取消',
            weekLabel: 'W',
            customRangeLabel: 'Custom Range',
            daysOfWeek:["日","一","二","三","四","五","六"],
            monthNames: ["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]
        }
    }, function(start, end, label) {
        $('#cTime_end').val(start.format('YYYY-MM-DD HH:mm:ss'));
    });
    $('#cTime_end').val("");//清空控件默认时间

    //日期时间查询条件不为空的情况下，给控件赋值
    if($("#cTimeS_hidden").val() != null || $("#cTimeS_hidden").val() != ""){
        $("#cTime_start").val($("#cTimeS_hidden").val());
    }
    if($("#cTimeE_hidden").val() != null || $("#cTimeE_hidden").val() != ""){
        $("#cTime_end").val($("#cTimeE_hidden").val());
    }


  //支付弹框
  // $('#md_edit_price').on('hide.bs.modal', function (event) {
  //     var form = window.form_edit_price;
  //     form.reset();
  // });
  // $('#md_edit_price').on('show.bs.modal', function (event) {
  //     var _e = $(event.relatedTarget);
  //     var product_id = _e.data("product_id");
  //     var proname = _e.data("proname");
  //     var procode = _e.data("procode");
  //     var modal = $(this);
  //     var form = window.form_edit_price;
  //     form.productid.value = product_id;
  //     form.productname.value = proname;
  //     form.productcode.value = procode;
  // });

  //费用提交 直接进入支付界面
  // $("[name='btn_save_price']").click(function () {
  //    var form = window.form_edit_price;
  //    if(form.price.value==''||form.price.value==null){
  //    	bootbox.balert("请输入每瓶支付的费用！");
  //    	return false ;
  //    }
  //    window.location.href="/payment/detail?price="+form.price.value+"&product_id="+form.productid.value+"&proname="+form.productname.value+"&procode="+form.productcode.value;
  // });
  //进入明细界面
  // $("[name='btn_detail']").click(function(){
	// 	var product_id = $(this).data("product_id");
	// 	var proname = $(this).data("proname");
	// 	var procode = $(this).data("procode");
	// 	var c_time = $(this).data("time");
	//
	// 	window.location.href="/paymentoff/detail?product_id="+product_id+"&proname="+proname+"&procode="+procode+"&c_time="+c_time;
	//
	// });

    //数据导出
    $("[name='btn_export']").click(function () {
        var proName = $("[name='proName']").val();
        var saleman = $("[name='saleman']").val();
        var timeLimitStart = $("[name='timeLimitStart']").val();
        var timeLimitEnd = $("[name='timeLimitEnd']").val();

        //有数据时才能导出
        if($("#resultTotal_hidden").val() != 0){
            bootbox.bconfirm("确定是否导出？", function (re) {
                if (re) {
                     var url="/salesmanCash/exportPaid?proName="+proName + "&saleman="+saleman
                     +"&timeLimitStart="+timeLimitStart+"&timeLimitEnd="+timeLimitEnd;
                     window.open(url);
                }
            });
        }else{
            bootbox.balert("没有数据，无法导出!");
        }
    });
});